package com.cxhc.app.api;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.cxhc.system.domain.app.RpRoadShop;
import com.cxhc.system.service.app.IRpRoadShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cxhc.common.core.controller.BaseController;
import com.cxhc.common.core.domain.AjaxResult;
import com.cxhc.common.utils.poi.ExcelUtil;
import com.cxhc.common.core.page.TableDataInfo;

/**
 * 沿街店铺检查Controller
 * 
 * @author Dhq
 * @date 2024-09-23
 */
@RestController
@RequestMapping("/api/roadShop")
public class ApiRpRoadShop extends BaseController
{
    @Autowired
    private IRpRoadShopService rpRoadShopService;

    /**
     * 查询沿街店铺检查列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RpRoadShop rpRoadShop)
    {
        startPage();
        List<RpRoadShop> list = rpRoadShopService.selectRpRoadShopList(rpRoadShop);
        return getDataTable(list);
    }

    /**
     * 导出沿街店铺检查列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, RpRoadShop rpRoadShop)
    {
        List<RpRoadShop> list = rpRoadShopService.selectRpRoadShopList(rpRoadShop);
        ExcelUtil<RpRoadShop> util = new ExcelUtil<RpRoadShop>(RpRoadShop.class);
        util.exportExcel(response, list, "沿街店铺检查数据");
    }

    /**
     * 获取沿街店铺检查详细信息
     */
    @GetMapping(value = "/detail/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rpRoadShopService.selectRpRoadShopById(id));
    }

    /**
     * 新增沿街店铺检查
     */
    @PostMapping("/insert")
    public AjaxResult add(@RequestBody RpRoadShop rpRoadShop)

    {
        return toAjax(rpRoadShopService.insertRpRoadShop(rpRoadShop));
    }

    /**
     * 修改沿街店铺检查
     */
    @PostMapping("/update")
    public AjaxResult edit(@RequestBody RpRoadShop rpRoadShop)
    {
        return toAjax(rpRoadShopService.updateRpRoadShop(rpRoadShop));
    }

    /**
     * 删除沿街店铺检查
     */
    @GetMapping(value = "/delete/{id}")
    public AjaxResult remove(@PathVariable Long id)
    {
        return toAjax(rpRoadShopService.deleteRpRoadShopById(id));
    }
}
